package accounts;

import tester.cobertura.Instrument;

/**
 * <h>Title : Account</h>
 * <p>This is an account</p>
 * @author Adam Blackwell & Ryan Cassidy
 */
@Instrument
public abstract class Account {
	protected int num;      
	protected String name;  
	protected int balance;  
	protected String owner;
	protected String classType = this.getClass().toString(); // Will this work... Yes!!

	/**
	 * @param num The account number.
	 * @param name The name of the account.
	 * @param balance How much money, in dollars, is in the account.
	 * @param owner The person who owns the account.
	 */
	public Account(int num, String name, int balance, String owner) {
		this.num = num;
		this.name = name;
		this.balance = balance;
		this.owner = owner;
	}

	/**
	 * Checks if an account's balance is under the given integer.
	 * @param n
	 * @return boolean
	 */
	public boolean underp(int n){
		return this.balance < n;
	}
	
	/**
	 * Checks if the given owner owns an account.
	 * @param p
	 * @return boolean
	 */
	public boolean ownerp(String p){
		return this.owner.equals(p);
	}
	
	/**
	 * Checks if the account is explicitly a Savings Account.
	 * @param act
	 * @return boolean
	 */
	public boolean savingsp(Account act){
		return act.getClass() == Savings.class;
	}

	/**
	 * Checks if the account is explicitly a Savings Account.
	 * @param act
	 * @return boolean
	 */
	public boolean checkingp(Account act){
		return act.getClass() == Checking.class;
	}

	/**
	 * Checks if the account is explicitly a Savings Account.
	 * @param act
	 * @return boolean
	 */
	public boolean creditp(Account act){
		return act.getClass() == Credit.class;
	}

	/**
	 * Checks if the account is explicitly a Savings Account.
	 * @param act
	 * @return boolean
	 */
	public boolean premiumCheckingp(Account act){
		return act.getClass() == PremiumChecking.class;
	}

	/**
	 * Withdraws a given amount from an account.
	 * @param amt
	 * @return Account
	 */
	public abstract Account withdraw(int amt);

	/**
	 * Deposits a given amount into an account.
	 * @param amt
	 * @return Returns the account.
	 */
	public abstract Account deposit(int amt);
	
	
	/** 
	 * Returns the String representation of a list, 
	 * (each elements String representation with spaces in between.)
	 * @see java.lang.Object#toString()
	 * @return String
	 */
	public String toString() {
		return this.owner + "'s-" + this.name;
	}
	
	// Getters
	/**
	 * @return the num
	 */
	public int getNum() {
		return num;
	}
	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}
	/**
	 * @return the balance
	 */
	public int getBalance() {
		return balance;
	}
	/**
	 * @return the owner
	 */
	public String getOwner() {
		return owner;
	}
	/**
	 * @return the getClass
	 */
	public String getClassType() {
		return classType;
	}
}
